package com.gexin.common.app;

import com.gexin.common.app.JpushModel.PushType;
import com.jfinal.log.Log;

import java.util.HashMap;

/**
 * 极光推送的接口
 * 
 * @author 肖得明
 * 
 */
public class JpushTools extends JpushToolsApi {
	@SuppressWarnings("unused")
	private  static Log log = Log.getLog(JpushTools.class);
	public static void main(String[] args) {
		//SendJpulsMessagg("推送测试", "推送内容", "13065ffa4e3f07d1b83", "1", null);
		JpushTools.SendMessageToAppNeibu(true, "您的账户在其他的地方登录了！", "190e35f7e02e1247f4b", JpushMsgType.Type_Logout, null);


/*		//1a0018970a91fe7be5d
		//161a3797c823edaa132
		JpushModel bean  = new JpushModel();
		bean.setPush_type(PushType.outer);
		bean.setTitle("订单退款");
		bean.setCentent("可能是您订单超出配送区域或因商品无货,不便之处请谅解,点击查询详细");
		bean.setJpushid("190e35f7e02e1247f4b");
		//bean.setAudience(Audience.all());//给全部认推送
		bean.setType(JpushMsgType.Adv_Notify);
		Ret ret =  Ret.create();
		ret.put("type","url");
		ret.put("data","http://www.baidu.com");
		ret.put("title","百度活动");
		*//*bean.setData(ret.getData());*//*
		bean.startPush();*/
	}
	public static void SendJpulsMessagg(String title,String centent,String registrationId,String type,Object data) {
		JpushModel bean  = new JpushModel();
		bean.setPush_type(PushType.outer);
		bean.setTitle(title);
		bean.setCentent(centent);
		bean.setJpushid(registrationId);
		bean.setType(type);
		bean.setData(data==null?new HashMap<>():data);
		bean.startPush();
	}

 
		 /**
		  * 推送消息到内部
		  * @param regid 唯一编号
		  * @param type   类型
		  * @param data  数据
		  */
		public static void SendMessageToAppNeibu(Boolean silent, String content , String regid,String type,Object data){
			// Jpuls_App_InMessage(Audience.registrationId(regid),type,type,data,userType);
			JpushModel bean  = new JpushModel();
			bean.setPush_type(PushType.inner);
			bean.setJpushid(regid);
			bean.setType(type);
			bean.setData(data==null?new HashMap<>():data);
			bean.setSilent(silent);
			bean.setCentent(content==null?"":content);
			bean.startPush();	
		}
	 
}
